package com.baomibing.flow.dto;

import com.baomibing.core.process.SProcess;
import com.baomibing.core.process.StateProcess;
import com.baomibing.flow.action.FlowAction;
import com.baomibing.flow.state.FlowState;
import com.baomibing.flow.ui.UWorkFlow;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;
import java.util.EnumSet;

/**
 * SysFlowDto
 *
 * @author frog 2023/10/13 16:53
 * @version 1.0.0
 **/
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SysFlowDto extends StateProcess<FlowState, FlowAction> {

    private String id;

    private String name;

    private String style;

    private String processes;

    private String state;

    private String groupId;

    private String startNode;

    private String nodes;

    private String endNode;

    private String viewPort;

    private String note;

    private String flowVersion;

    private Date createTime;

    private UWorkFlow data;


    @Override
    public SProcess<FlowState, FlowAction> initProcess() {
        return getBuilder()
                .initState(FlowState.ACTIVE).deleteable(EnumSet.of(FlowState.UNACTIVE))
                .process().source(FlowState.UNACTIVE).target(FlowState.ACTIVE).action(FlowAction.USE)
                .and()
                .process().source(FlowState.ACTIVE).target(FlowState.UNACTIVE).action(FlowAction.STOP)
                .build();
    }

}


